home *** CD-ROM | disk | FTP | other *** search
- /* P892.C --- BIBLE */
- #include <conio.h>
- #define ESC '\033'
- char *fgnd[] = {"BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA", "BROWN",
- "LIGHGRAY", "DARKGREY", "LIGHTBLUE", "LIGHTGREEN", "LIGHTCYAN",
- "LIGHTRED", "LIGHTMAGENTA", "YELLOW", "WHITE"};
- char *bgnd[] = {"BLACK", "BLUE", "GREEN", "CYAN", "RED", "MAGENTA",
- "BROWN", "LIGHTGRAY"};
- char *blink[] = {"NOBLINK", "BLINK"};
- static int column = 0, row = 0, xypos[3][2] = {3, 4, 23, 4, 43, 4},
- numattrs[3] = {16, 8, 2}, selection[3] = {7, 0, 0};
- static char **colorlist[3] = {fgnd, bgnd, blink};
- main()
- {
- int i, j, c, attr;
- window(10, 1, 70, 24);
- clrscr();
- textattr(LIGHTGRAY << 4 + BLACK);
- gotoxy(10, 1);
- cputs("Use Tab and Enter to move along columns");
- gotoxy(20, 2);
- cputs("Press ESC to exit");
- textattr(LIGHTGRAY);
- for(i = 0; i < 3; i++)
- {
- for(j = 0; j < numattrs[i]; j++)
- {
- gotoxy(xypos[i][0], xypos[i][1] + j);
- cputs((colorlist[i])[j]);
- }
- }
- while((c = getch()) != ESC)
- {
- textattr(WHITE + (BLACK << 4));
- if(c == '\t')
- {
- column = (column + 1) % 3;
- }
- if(c == '\r')
- {
- gotoxy(xypos[column][0] - 1, xypos[column][1] +
- selection[column]);
- putch(' ');
- selection[column] = (selection[column] + 1)
- % numattrs[column];
- }
- for(i = 0; i < 3; i++)
- {
- gotoxy(xypos[i][0] - 1, xypos[i][1] + selection[i]);
- putch('*');
- }
- attr = (selection[1] << 4) + selection[0];
- if(selection[2] != 0)
- attr += BLINK;
- textattr(attr);
- gotoxy(1, 20);
- cputs("This is how the current text attribute looks");
- }
- }